<template>
  <view @click="handleBack()">
    <uv-icon size="40rpx" :color="color" name="home" v-if="isHome"></uv-icon>
    <uv-icon size="40rpx" :color="color" name="arrow-left" v-else></uv-icon>
  </view>
</template>

<script>
export default {
  name: 'navLeft',
  props: {
    color: {
      type: String,
      default: '#333',
    },
  },
  data() {
    return {}
  },
  computed: {
    isHome() {
      const pages = getCurrentPages()
      return pages.length === 1
    },
  },
  methods: {
    handleBack() {
      if (this.isHome) {
        // uni.switchTab({ url: '/pages/index/index' })
        uni.redirectTo({ url: '/pages/index/index' })
      } else {
        uni.navigateBack()
      }
    },
  },
}
</script>

<style lang="scss" scoped></style>
